﻿using System;
using System.Windows;
using Csla.Xaml;
using Accounting.Library;

namespace csla4Skeleton.UI.SL.NghiepVu.Kho.K_TonKho
{
    public partial class K_TonKho_ListViewModel : ViewModel<K_TonKhoList>
    {

        public K_TonKho_ListViewModel(string mode)
        {
            BeginRefresh("GetK_TonKhoList", mode);

        }
        
        public void GetK_TonKho_ListViewModel(string mode)
        {
            BeginRefresh("GetK_TonKhoList", mode);
        }

        public static readonly DependencyProperty SelectedItemProperty =
          DependencyProperty.Register("SelectedItem", typeof(K_TonKhoInfo), typeof(K_TonKho_ListViewModel), null);
        public K_TonKhoInfo SelectedItem
        {
            get { return (K_TonKhoInfo)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }

        public void DeleteK_TonKho(object sender, ExecuteEventArgs e)
        {
            if (e.MethodParameter != null)
            {
                //cast OrderID parameter
                int Khoa = Int16.Parse(e.MethodParameter.ToString());
                this.IsBusy = true;
                Accounting.Library.K_TonKho.DeleteK_TonKho(Khoa, (o, ex) =>
                {
                    BeginRefresh("GetK_TonKhoList",BusinessConfiguration.Configuration.GridViewFetchMode);
                });
                this.IsBusy = false;
            }
        }	
    }
}
